//
//  main.m
//  dictDemo
//
//  Created by zhouxiaobo on 15/10/24.
//  Copyright © 2015年 mapath. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"zhou",@"1",@"xiao",@"2",@"bo",@"3",nil];
        NSDictionary *dict1 = @{@"1":@"yu",@"2":@"li",@"3":@"jun"};
        
        NSEnumerator *enum1 = [dict1 keyEnumerator];  //迭代key
        id obj = nil;
        while(obj = [enum1 nextObject]){
            NSLog(@"%@",obj);
        }
        
        NSEnumerator *enum2 = [dict objectEnumerator];  //迭代value
        while(obj = [enum2 nextObject]){
            NSLog(@"%@",obj);
        }
        
        //快速打印
        for(obj in dict1){
            NSLog(@"%@", obj); //打印key
            NSLog(@"%@",[dict1 objectForKey:obj]); //打印value
        }
        
        //---------------------------------------------------------------//
        NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
        [dict2 setObject:@"zhou" forKey:@"1"];
        [dict2 setObject:@"yu" forKey:@"2"];
        [dict2 setObject:@"heng" forKey:@"3"];
        
        NSLog(@"%@",dict2);
        
        NSEnumerator *enum3 = [dict2 keyEnumerator];
        while (obj = [enum3 nextObject]) {
            NSLog(@"Key:%@, value:%@",obj,[dict2 valueForKey:obj]);
        }
        
        [dict2 setObject:@"tempvalue" forKey:@"2"];
        NSLog(@"%@",dict2);
        
        [dict2 removeObjectForKey:@"2"];
        NSLog(@"%@",dict2);
    }
    return 0;
}
